package com.kun.permiss.controller;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;

/**
 * @author fangkun
 * @create 2023-05-15-10:16
 *
 *
 */
@RestController
public class HelloController {

    @GetMapping("/hello")
    public void hello(){
        Collection<? extends GrantedAuthority> authorities = SecurityContextHolder.getContext().getAuthentication().getAuthorities();
        for (GrantedAuthority authority : authorities){
            System.out.println("authority: "+authority);
        }
    }
}
